package com.devunion.admin.client;

import com.devunion.reader.client.Application;
import com.devunion.reader.client.panel.SimpleSearchPanel;
import com.devunion.reader.client.panel.AdvancedSearchPanel;
import com.devunion.reader.client.panel.UserManagementPanel;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.event.ToolBarEvent;
import com.extjs.gxt.ui.client.Style;
import com.extjs.gxt.ui.client.widget.layout.RowData;

/**
 * @author Aliaksandr Tsimashenka 08.03.2010 : 21:39:32
 */
public class Admin extends Application {
    @Override
    protected SimpleSearchPanel getSearchPanel() {
        final AdvancedSearchPanel advancedSearchPanel = new AdvancedSearchPanel();
        advancedSearchPanel.getAppToolItem().addSelectionListener(new SelectionListener<ToolBarEvent>() {
            public void componentSelected(ToolBarEvent toolBarEvent) {
                init(advancedSearchPanel);
            }
        });

        advancedSearchPanel.getManagementToolItem().addSelectionListener(new SelectionListener<ToolBarEvent>() {
            public void componentSelected(ToolBarEvent toolBarEvent) {
                getViewport().clearAll();
                getViewport().getPanel(Style.LayoutRegion.CENTER)
                        .add(new UserManagementPanel(), new RowData(1d, 1d));
                getViewport().layout();
            }
        });
        return advancedSearchPanel;
    }
}
